package cn.nkpro.elcube.cloud;

import cn.nkpro.elcube.cloud.idds.NkCloudIddsClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Map;

/**
 * Cloud 配置文件
 */
@ConditionalOnProperty(
        prefix = "dubbo",
        name = {"enabled"},
        matchIfMissing = true
)
@Configuration
public class NkCloudConfig{

    @Autowired
    private NkCloudProperties cloudProperties;

    @Bean
    public Map<String,Object> cloudProviderAuths(){
        return cloudProperties.getProviderAuths();
    }


    @ConditionalOnProperty(
            prefix = "nk.cloud.idds",
            name = {"uris","name"}
    )
    @Bean
    public NkCloudIddsClient nkCloudIddsClient(){
        return new NkCloudIddsClient(cloudProperties);
    }
}
